package com.protocol;

import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;

/**
 * �첽����ͨ����
 * 
 * @author У��
 * @version 1.0.1
 * @date 2013-3-1 16:26:28
 */
public abstract class AsyncThread extends AsyncTask<Object, Object, Object> {
	private Context context;
	ProgressDialog pdialog;

	public AsyncThread(Context context) {
		this.context = context;
	}

	/**
	 * �û��Զ��庯��
	 * 
	 * @return ����Object��doInBackground()����
	 */
	public abstract Object executeRun(Object... params);

	/**
	 * ִ��ǰ��ʾ(UI���)
	 */
	public abstract void executeBefore();

	/**
	 * ִ�к���ʾ(UI���)
	 * 
	 * @param obj
	 */
	public abstract void executeAfter(Object obj);

	/**
	 * �˴�������ݴ���ҵ��
	 */
	@Override
	protected Object doInBackground(Object... params) {
		try {
			return executeRun(params);
		} catch (Exception ex) {
//			AppInfo.postException(ex);
			return params[0] = "";
		}
	}

	@Override
	protected void onPreExecute() {
		try {
			executeBefore();
		} catch (Exception e) {	
//			AppInfo.postException(e);
			}
	}

	@Override
	protected void onPostExecute(Object obj) {
		try {
			executeAfter(obj);
		} catch (Exception e) {	
//			AppInfo.postException(e);
			e.printStackTrace();
			}
	}

	public void start() {
		super.execute(context);
	}

}